1

Application的初始化

$app = new Illuminate\Foundation\Application(
    realpath(__DIR__.'/../')
);

注册基本的绑定

$this->instance();

将对应的alias注册到instances数组中

$this->registerBaseBindings();

appContainer绑定到实例数组中,并且实现方式都是Application的实例

$this->instance('app', $this);
$this->instance('Illuminate\Container\Container', $this);

注册基本的服务提供者

$this->register()

将注册的provider放到$this->serviceProviders[]

$this->registerBaseServiceProviders()

将注册的provider放到$this->serviceProviders[] 中,直接触发provider中的register()方法,如果应用已经booted,然后还要触发provider中的boot方法

$this->register(new EventServiceProvider($this));
$this->register(new RoutingServiceProvider($this));

注册核心容器别名

$this->registerCoreContainerAliases()

将类地址注册到$this->aliases中,why?

facade的实现

就是通过class_alias来实现的类别名

  1. app启动的时候kernel通过handle,触发了app中的bootstrapwith,并且触发了每个列表中类实现中的bootstrap方法

  2. bootstrapwith加载了所有启动需要的一个列表,

  3. 列表中的RegisterFacade中有个bootstrap被触发,然后AliasLoader加载了config中的aliases别名配置,执行register

  4. register通过autoload注册,内部实现通过class_alias

helpers辅助函数的加载

通过autoload,加载了autoload_files,然后直接进行了require

return array(
    '1d1b89d124cc9cb8219922c9d5569199' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest.php',
    '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
    '667aeda72477189d0494fecd327c3641' => $vendorDir . '/symfony/var-dumper/Resources/functions/dump.php',
    '2c102faa651ef8ea5874edb585946bce' => $vendorDir . '/swiftmailer/swiftmailer/lib/swift_required.php',
    '5255c38a0faeba867671b61dfda6d864' => $vendorDir . '/paragonie/random_compat/lib/random.php',
    'bd9634f2d41831496de0d3dfe4c94881' => $vendorDir . '/symfony/polyfill-php56/bootstrap.php',
    'e7223560d890eab89cda23685e711e2c' => $vendorDir . '/psy/psysh/src/Psy/functions.php',
    'f0906e6318348a765ffb6eb24e0d0938' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/helpers.php',
    '58571171fd5812e6e447dce228f52f4d' => $vendorDir . '/laravel/framework/src/Illuminate/Support/helpers.php',
);

Hamcrest

这是一个类似c语言的assert.h的一个东西,断言

/symfony/polyfill-mbstring

« Symfony is a set of PHP Components, a Web Application framework, a Philosophy, and a Community — all working together in harmony. »

这是一个通过php来实现mbstring扩展的方法集合,如果没有安装mbstring扩展,可以通过这个来实现。

/symfony/var-dumper/Resources/functions/dump.php

可以代替var_dump的方法
The VarDumper component provides mechanisms for walking through any arbitrary PHP variable. Built on top, it provides a better dump() function that you can use instead of var_dump.

/swiftmailer/swiftmailer/lib/swift_required.php

发送邮件用的类
Free Feature-rich PHP Mailer

Swift Mailer integrates into any web app written in PHP 5, offering a flexible and elegant object-oriented approach to sending emails with a multitude of features.

Send emails using SMTP, sendmail, postfix or a custom Transport implementation of your own

Support servers that require username & password and/or encryption
Protect from header injection attacks without stripping request data content
Send MIME compliant HTML/multipart emails
Use event-driven plugins to customize the library
Handle large attachments and inline/embedded images with low memory use

paragonie/random_compat/lib/random.php

没找到相应的说明,但是应该是生成一个随机数

/symfony/polyfill-php56/bootstrap.php

一个hash_equals和ldap_escape 不过不知道是啥意思
什么是时序攻击?什么是ldap?

/psy/psysh/src/Psy/functions.php

一个交互控制台


jaysun
507 声望25 粉丝

Code is law